package mo.offer_special;

@SuppressWarnings("DuplicatedCode")
public class L092 {

    public int minFlipsMonoIncr(String s) {
        int flip0 = 0;
        int flip1 = 0;
        for (char c : s.toCharArray()) {
            int newFlip0 = flip0 + (c == '0' ? 0 : 1);
            int newFlip1 = Math.min(flip0, flip1 + (c == '1' ? 0 : 1));
            flip0 = newFlip0;
            flip1 = newFlip1;
        }
        return Math.min(flip0, flip1);
    }

}
